/*
 * jQuery  validator extend
 */
jQuery.validator.setDefaults({
	highlight: function(input) {
		$(input).removeClass("v-style-valid").addClass("v-style-error");		
	},
	unhighlight: function(input) {
		$(input).removeClass("v-style-error").addClass("v-style-valid");;
	},
	errorClass:"v-error",
	validClass:"v-valid",
	ignoreTitle:true,
	success:function (label){label.addClass('v-valid');},
	onfocusin:function(element){	
			this.lastActive = element;				
			// hide error label and remove error class on focus if enabled
			if ( this.settings.focusCleanup && !this.blockFocusCleanup ) {
				this.settings.unhighlight && this.settings.unhighlight.call( this, element, this.settings.errorClass, this.settings.validClass );
				this.errorsFor(element).hide();
			};
			//title tips 
			if (element.title.length!=0)
			{
				this.showLabel(element,element.title);
				var label = this.errorsFor( element );
				label.removeClass().addClass(this.settings.errorClass).addClass('v-tips');			
			}		
		},
	errorElement:"div"
});
jQuery.extend(jQuery.validator.messages, {
        required: "必选字段",
		remote: "请修正该字段",
		email: "请输入正确格式的电子邮件",
		url: "请输入合法的网址",
		date: "请输入合法的日期",
		dateISO: "请输入合法的日期 (ISO).",
		number: "请输入合法的数字",
		digits: "只能输入整数",
		creditcard: "请输入合法的信用卡号",
		equalTo: "请再次输入相同的值",
		accept: "请输入拥有合法后缀名的字符串",
		maxlength: jQuery.validator.format("请输入一个长度最多是 {0} 的字符串"),
		minlength: jQuery.validator.format("请输入一个长度最少是 {0} 的字符串"),
		rangelength: jQuery.validator.format("请输入一个长度介于 {0} 和 {1} 之间的字符串"),
		range: jQuery.validator.format("请输入一个介于 {0} 和 {1} 之间的值"),
		max: jQuery.validator.format("请输入一个最大为 {0} 的值"),
		min: jQuery.validator.format("请输入一个最小为 {0} 的值")
});
